<template>
  <div class="sign_list">
    <TeamInfo></TeamInfo>

    <div class="data_list">
      <div class="data">
        <div class="info">
          <div class="title">
            本区赛事
            <span @click="router.push('/match/sign_up_list')" class="link">
              报名记录</span
            >
          </div>
          <div class="attr-hint" v-if="info.haveJinJi">
            (您有赛事<span>获得晋级资格</span>，请前往报名记录查看与操作)
          </div>
        </div>
        <div
          class="item item-sign"
          v-for="(item, index) in pageInfo.list"
          :key="index"
        >
          <div class="title">{{ item.match_name }}</div>
          <div class="attr">比赛时间：{{ item.begindate }}</div>

          <div class="attr">报名起止时间：{{ item.signdate }}</div>
          <div class="sign-btn" @click="handleDetail(item.id)" v-if="item.signflag=='1'">去报名</div>
        </div>
      </div>
      <div class="data-hint">我是有底线的~</div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
import baseService from "@/service/baseService";
import {getCache, setCache} from "@/utils/cache";
import { ElMessage } from "element-plus";
import TeamInfo from "@/components/user/TeamInfo.vue";
let router = useRouter();
let info =ref({
  haveJinJi:false,
  team:getCache( "CacheToken",{ isSessionStorage: true }, {})
});
let pageInfo = ref({
  list: [

  ],
});
const query = () => {
  baseService
    .get("/front/fast/match/match/page?pageSize=10", {
      pageNumber: 1,
      pageSize: 99,
      loginType: "wap",
    })
    .then((res) => {
      console.log(res);
      pageInfo.value.list = res.data.list;
    });
};
const queryHaveJinJi=()=>{
  baseService.get("/front/spmatchItemTeam/queryRise?teamId=" + info.value.team.teamId).then((res: any) => {
    info.value.haveJinJi = (res.data.total>0) ;
  });
}
query();
queryHaveJinJi();

const handleDetail = (id:number) => {
  router.push({path:"/match/info",query:{id:id}} );
};
</script>

<style lang="scss" scoped>
@import "./style.scss";
</style>
